<?php

namespace App\Http\Controllers\Test;

use Auth;
use Biz\Models\User\User;
use Biz\Services\User\UserService;

/**
 * ValidatorController.
 *
 * @license [http://www.85do.com] [杭州永奥网络科技有限公司]
 * @copyright Copyright (c) 2018-2026 Hangzhou Yongao Technology Co., Ltd. All rights reserved.
 */
class PassportController extends Controller
{
    /**
     * @var mixed
     */
    protected $service;

    /**
     * RepositoryController constructor.
     *
     * @param UserService $service
     */
    public function __construct(UserService $service)
    {
        $this->service = $service;
        $this->middleware('auth:api', ['only' => [
            'index',
        ]]);
    }

    /**
     * Home.
     *
     * @return string
     */
    public function index()
    {
        return Auth::user();
    }

    /**
     * Login.
     *
     * @return string
     */
    public function login()
    {
        $user = $this->service->find(1);

        return $user->createToken($user->id);
    }
}
